package org.example.udp;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.util.Scanner;

public class UdpClient {
    public static void main(String[] args)throws Exception {
        DatagramSocket socket = new DatagramSocket();
        Scanner scanner = new Scanner(System.in);
        System.out.println("退出请输入‘q’");
        InetAddress address = InetAddress.getByName("192.168.127.1");
        while(true){
            String data = scanner.next();
            if (data.equals("q")) break;
            byte[] bytes = data.getBytes();
            DatagramPacket packet = new DatagramPacket(bytes, bytes.length,address,8888);
            socket.send(packet);
        }
        socket.close();
    }
}
